<?php

class Wlib_Controller_Action_Helper_ControllerTitle extends Zend_Controller_Action_Helper_Abstract
{
    protected $_keyPrefix = 'action_title_';

    public function postDispatch()
    {
        $action = $this->getRequest()->getActionName();
        $key = $this->getKeyPrefix() . $action;

        $view = $this->getActionController()->view;
        if($view->translate()->getTranslator()->isTranslated($key)) {
            $title = $view->translate($key);
            $view->headTitle($title);
        }
    }

    public function getKeyPrefix()
    {
        return $this->_keyPrefix;
    }

    public function setKeyPrefix($keyPrefix)
    {
        $this->_keyPrefix = $keyPrefix;
        return $this;
    }
}
